package com.leyantech.ecp.agenx.web.filter;

import com.leyantech.ecp.agenx.common.service.StoreConfigService;
import com.leyantech.ecp.agenx.web.AuthMessage;

import com.google.inject.Inject;
import lombok.extern.slf4j.Slf4j;

/**
 * @author eahau, {@literal <eahau@foxmail.com>}
 * @date 2022-11-16.
 */
@Slf4j
public class SalesInfoFilter implements AuthFilter {

  private final StoreConfigService storeConfigService;

  @Inject
  public SalesInfoFilter(StoreConfigService storeConfigService) {
    this.storeConfigService = storeConfigService;
  }

  @Override
  public boolean test(AuthMessage authMessage) {
    final String storeId = authMessage.getStoreId();
    final boolean enable = storeConfigService.isSalesSwitchFlagOn(storeId);
    if (!enable) {
      log.info("{} seat isn't enable.", storeId);
    }
    return enable;
  }

}
